<?php

declare(strict_types=1);

namespace App\Amqp\Consumer;

use Hyperf\Amqp\Result;
use Hyperf\Di\Annotation\Inject;
use Hyperf\Logger\LoggerFactory;
use PhpAmqpLib\Message\AMQPMessage;
use Hyperf\Amqp\Annotation\Consumer;
use Hyperf\Amqp\Message\ConsumerMessage;

#[Consumer(exchange: 'hyperf', routingKey: 'hyperf', queue: 'hyperf', name: "QueueConsumer", nums: 1, enable: false, maxConsumption: 3)]
class QueueConsumer extends ConsumerMessage
{
    #[Inject]
    private LoggerFactory $logger;

    public function consumeMessage($data, AMQPMessage $message): Result
    {
        $this->logger->get('queue')->info('Receive message: ', $data);
        return Result::ACK;
    }
}
